package stack.era.presentation;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;

import javax.swing.JProgressBar;
import javax.swing.JScrollBar;

import stack.era.constants.WorldAttributes.Month;
import stack.era.domain.DomainHome;

public class ERAWaitingProgressBar extends JProgressBar {

	private static final long serialVersionUID = 8604056808171350423L;

	private int hour, day, year;
	private Month month;

	public ERAWaitingProgressBar(int hoursToWait) {
		super(JScrollBar.HORIZONTAL, 0, hoursToWait);

		this.setValue(0);
	}

	@Override
	public void setValue(int value) {
		super.setValue(value);
		DomainHome domain = DomainHome.getInstance();
		this.hour = domain.getWorld().getHour();
		this.day = domain.getWorld().getDay();
		this.month = domain.getWorld().getMonth();
		this.year = domain.getWorld().getYear();
	}

	@Override
	public void paint(Graphics g) {
		super.paint(g);

		Graphics2D g2d = (Graphics2D) g.create();
		g2d.setColor(Color.BLACK);
		g2d.drawString(month.getFullName()
				+ " "
				+ day
				+ ", Year "
				+ this.year
				+ " : "
				+ (this.hour > 12 ? this.hour - 12 + ":00 PM" : this.hour
						+ ":00 AM"), 40, 25);
		g2d.dispose();
	}

}
